package com.imot.controller;

import com.imot.response.Result;
import com.imot.service.FaultDiagnosisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDateTime;

/**
 * ClassName: FaultDiagnosisController
 * Description:
 * date: 2023/11/16 13:47
 *
 * @author imot-jiah.wang
 */
@Api(tags = "故障诊断控制器")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/faultDiagnosis")
public class FaultDiagnosisController {
    private final FaultDiagnosisService faultDiagnosisService;

    //------------------------故障告警---------------------------------
    @ApiOperation("故障告警波形图")
    @PostMapping("/getFaultParameterWaveform")
    public Result getFaultParameterWaveform(@RequestParam(required = false) String parameterName,
                                            @RequestParam(required = false) LocalDateTime startTime,
                                            @RequestParam(required = false) LocalDateTime endTime){
        Result result = faultDiagnosisService.faultDiagnosisService( parameterName,startTime,endTime);
        return result;
    }
    //------------------------故障告警---------------------------------



    //------------------------智能诊断---------------------------------
    @ApiOperation("开始诊断")
    @PostMapping("/diagnosisStart")
    public Result getDiagnosisStart(@RequestParam("file") MultipartFile file){
        Result result = faultDiagnosisService.getDiagnosisStart(file);
        return result;
    }

    @ApiOperation("实时诊断")
    @GetMapping("/carryOutLiveCheckup")
    public Result carryOutLiveCheckup(){
        Result result = faultDiagnosisService.carryOutLiveCheckup();
        return result;
    }

    @ApiOperation("查看故障")
    @GetMapping("/confirmErrorCondition")
    public Result confirmErrorCondition(Integer id){

        Result result = faultDiagnosisService.confirmErrorCondition(id);
        return result;
    }
    //------------------------智能诊断---------------------------------



    //------------------------历史故障---------------------------------
    @ApiOperation("获取最上面的状态栏")
    @GetMapping("/confirmTopFaultStatus")
    public Result confirmTopFaultStatus(){
        Result result = faultDiagnosisService.confirmTopFaultStatus();
        return result;
    }

    @ApiOperation("历史故障")
    @PostMapping("/getHistoryFault")
    public Result getHistoryFault(@RequestParam(required = false)LocalDateTime startTime,
                                  @RequestParam(required = false)LocalDateTime endTime,
                                  @RequestParam(required = false)Integer page,
                                  @RequestParam(required = false)Integer limit,
                                  @RequestParam(required = false)String faultType,
                                  @RequestParam(required = false)String deviceName){
        Result result = faultDiagnosisService.getHistoryFault(startTime,endTime,page,limit,faultType,deviceName);
        return result;
    }

    @ApiOperation("查看历史故障诊断报告")
    @GetMapping("/getHistoricalFaultDiagnosisReports")
    public Result getHistoricalFaultDiagnosisReports(Integer errorId){
        Result result = faultDiagnosisService.getHistoricalFaultDiagnosisReports(errorId);
        return result;
    }

    @ApiOperation("确认故障报告")
    @GetMapping("/confirmFaultReport")
    public Result confirmFaultReport(String reportName){
        Result result = faultDiagnosisService.confirmFaultReport(reportName);
        return result;
    }

    //------------------------历史故障---------------------------------
}

